home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#42 (Mar 89)
/
XCMD CODE
/
adspxcmd.p
next >
Wrap
Text File
|
1989-01-10
|
6KB
|
148 lines
(********************************************************************)
(* file: ADSPxcmd.p *)
(* version: .01ß *)
(* *)
(* ---------------------------------------------------------------- *)
(* By: Donald Koscheka and Nancy Rosenberg *)
(* Date: 1-Feb-88 *)
(* © Copyright 1988, Apple Computer, Inc. *)
(* All Rights Reserved *)
(* *)
(* ---------------------------------------------------------------- *)
(* Modification History *)
(* ---------------------------------------------------------------- *)
(* Date | By | Description *)
(* ---------------------------------------------------------------- *)
(* 1-Feb-88 | DK | file created *)
(* 13-May-88 | DK | Added user area to connection record *)
(* 13-May-88 | DK | Added File Transfer Record *)
(* ---------------------------------------------------------------- *)
(********************************************************************)
UNIT adspxcmd;
INTERFACE
USES Memtypes, QuickDraw, OSIntf, ToolIntf, AppleTalk, ADSP;
CONST
ASYNC = TRUE;
SYNC = FALSE;
{*** connection mode status ***}
NOP = 0;
REQ = 1;
ACK = 2;
EST = 3;
GLOBALNBPDATA = 28400;
GLOBALDSPDATA = 29337;
GLOBALSKTDATA = 21644;
DEFAULT_ERROR = 23220;
NO_ERROR = 22476;
MEM_ERROR = 31830;
NBPLSIZE = 120;
ATPBSIZE = 578; { the standard size of a "transaction" buffer }
INTERVAL = 20; { default retry interval 60 ticks = 10 secs. }
RETRY = 3; { retry count = 3: total = 3 * 60 = 30 secs. }
PORTBUSE = $291;
SPCONFIG = $1FB;
CLOSE_OK = 0;
RECEIVING = 1;
CLOSE_NOW = 2;
NEWLINE = $0D; { inserted after each entry in the zone info table }
aTalkVars = $2D8; { pointer to appletalk vars, aka aBusVars, mppVars }
sysABridge = $19; { Node address of a bridge [byte] }
sysNetNum = $1A; { This node's network number [word] }
{******** File Transfer Protocol ************}
NO_FORK = 0; { Currently not sending any data }
DATA_FORK = 1; { Currently sending the data fork of the file }
RESOURCE_FORK = 2; { Currently sending the resource fork of the file }
FINDER_FORK = 3; { Currently sending the finder bytes of a file }
FILE_NOT_READY = 0; { Not ready to send the file yet }
FILE_READY = 1; { ready to receive the file }
(************************************************************************************)
(* As long as you're asking... *)
(* *)
(* The following data blocks reference memory pointers rather than handles. This is *)
(* not an intentionally egregious use of the memory manager but rather a way to *)
(* insure that all of the data in the connection block is non-relocatable since *)
(* ADSP runs asynchronously, the data must always be presented to ADSP. Hypercard *)
(* doesn't seem to mind non-rels and tends to do a fairly good job of concatenating *)
(* them low in the heap (Hypercard is no slouch when it comes to nonrels either, so *)
(* we're just piggybacking our pointers on top of the large nonrel area at the start*)
(* of the Hypercard application heap). ça ne fait rien. *)
(************************************************************************************)
TYPE
LIntPtr = ^LongInt;
IntPtr = ^INTEGER;
CBPtr = ^Connection;
Connection = Packed Record
next : CBPtr; { pointer to the next block in the list }
last : CBPtr; { pointer to the last block in the list }
ccbRef : Integer; { reference number for this connection }
mode : Integer; { set to EST if the connection is open & ready }
adr : AddrBlock; { address of remote end (NIL if not connected) }
msg : Handle; { callback message for incoming data }
sendQ : Ptr; { buffer for sending to remote connection end }
recvQ : Ptr; { buffer for receiving from remote connection }
attn : Ptr; { buffer for attention messages }
outBuf : Handle; { where the outgoing data is placed }
inBuf : Handle; { where the input data goes }
attnBuf : Handle; { where the attention data goes }
remName : Handle; { the entity name of the remote end }
ccb : TRCCB; { pointer to the connection control block }
attnPB : DSPParamBlock; { attention messages parameter block }
dspPB : DSPParamBlock; { connection param block for this connection }
user : Handle; { place for user defined data. }
End;
ADSPPtr = ^ADSPBlock;
ADSPBlock = Packed Record { ADSP protocol data }
dspRefNum : Integer; { driver refnum for ADSP }
ccbref : Integer; { ccbRefNum for the connection listener }
addr : AddrBlock; { socket address of this entity }
ends : CBPtr; { list of established connections }
ccb : TRCCB; { ptr to listener connection control block }
pb : DSPParamBlock;{ parameter block for connection listener }
checkPoint : Integer; { set if we're in a callback now }
oldSelf : Byte; { old state of the self-send flag }
pad : Byte; { keep em even, steven }
End;
NBPPtr = ^NBPBlock;
NBPBlock = Packed Record
Registered : Integer; { true if we are already registered }
EntCount : Integer; { number of entities visible }
LookUpBuffer: Handle; { handle to the lookup buffer }
NTEntry : NamesTableEntry; { entry into the names table }
NBPLocal : array[1..NBPLSIZE] of char; { used internally by NBP }
END;
FXPtr = ^FXRecord;
FXRecord = Packed Record { File Transfer Record. }
Status : Integer; { state of the current connection }
Fork : Integer; { current for being transferred }
FilePtr : Ptr; { Data buffer for the transfer }
refNum : Integer; { reference id to the file }
Name : Str255; { file name }
io : paramBlockRec;{ io parameter block for the i/o }
END;
End.